import React, { Fragment } from "react";

function Item2(props) {
    const increment = () => {
        props.dispatch({ type: "INCREMENT", payload: 2 })
    }
    const decrement = () => {
        props.dispatch({ type: "DECREMENT", payload: 2 })
    }
    return (
        <Fragment>
            <div className="mt-3 alert alert-warning">
                当前值为：{props.num}
            </div>
            <div onClick={increment} className="btn-sm btn btn-warning">增加+2</div>
            <div onClick={decrement} className="ml-3 btn-sm btn btn-danger">减少-2</div>
        </Fragment>
    )
}

export default Item2